home *** CD-ROM | disk | FTP | other *** search
- Path: meenie.Princeton.EDU!john
- From: john@meenie.Princeton.EDU (John Saponara)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Need amiga-specific docs to solve BGUI problem? (LONG)
- Date: 12 Feb 1996 03:48:32 GMT
- Organization: Princeton University
- Distribution: world
- Message-ID: <4fmdag$1i2@cnn.Princeton.EDU>
- Reply-To: john@meenie.Princeton.EDU (John Saponara)
- NNTP-Posting-Host: meenie.princeton.edu
- Originator: john@meenie
-
-
- Hi folks,
-
- I am having trouble changing attribute values of BGUI gadgets.
- I understand there is documentation available for programming
- the amiga. My questions thus are two:
-
- 1. How does one get amiga-specific programming docs?
- Are they available in online form?
-
- 2. Below I list code that attempts to use the SetAttrs and
- SetGadgetAttrs calls to change label text or indicator
- value in several kinds of gadgets. Neither SetAttrs nor
- SetGadgetAttrs affect the gadget contents, tho SetGadgetAttrs
- freezes the mouse pointer briefly. Is my error apparent
- from this code?
-
- Thanks very much for any suggestions,
- John Saponara
-
- /********************* test.c ********************/
-
- #include "democode.h" /* listed below */
-
- /*
- ** One, shared, message port for all
- ** demo windows.
- **/
- struct MsgPort *SharedPort;
-
- /*
- ** Menus & gadget ID's.
- **/
- #define ID_QUIT 2L
- #define ID_INPUT 3L
-
- /*
- ** Notification map-lists.
- **/
- ULONG sl2in [] = { SLIDER_Level, INDIC_Level, TAG_END };
-
- /*
- ** Window objects.
- **/
- Object *WA_Main = NULL;
-
- /*
- ** Gadget objects from the main window.
- **/
-
- Object* quitButton;
- Object* inputSlider;
-
- /*
- These are the `output' gadgets whose displayed value
- I try to change in the Update function below.
- */
- Object* outputIndicator;
- Object* outputInfo;
- Object* outputString;
- Object* outputButton;
-
- /*
- ** Open main window.
- **/
- struct Window *OpenMainWindow( ULONG *appmask )
- {
- struct Window *window = NULL;
-
- WA_Main = WindowObject,
- WINDOW_Title, "testing BGUI",
- WINDOW_ScaleWidth, 100,
- WINDOW_SmartRefresh, TRUE,
- WINDOW_SharedPort, SharedPort,
- WINDOW_MasterGroup,
- VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
- StartMember, inputSlider = HorizSlider( "input", 0, 12, 0, ID_INPUT ), EndMember,
- StartMember, quitButton = XenKeyButton( "Quit", ID_QUIT ), EndMember,
- /*
- Set up several kinds of gadgets for attempted output.
- */
- StartMember, outputIndicator = IndicatorFormat( 0, 12, 0, IDJ_RIGHT, "%ld" ), EndMember,
- StartMember, outputInfo = InfoObject, INFO_TextFormat, ISEQ_C "info", EndObject, EndMember,
- StartMember, outputString = StringObject, LAB_Label, "string", EndObject, EndMember,
- StartMember, outputButton = ButtonObject, LAB_Label, "button", EndObject, EndMember,
- EndObject,
- EndObject;
-
- /*
- ** Object created OK?
- **/
- if ( WA_Main ) {
-
- /*
- ** Could connect slider to indicator, but instead I want to
- ** do a calculation with the slider value and display some result.
- ** See Update function below.
- **/
-
- /* AddMap( inputSlider, outputIndicator, sl2in ); */
-
- /*
- ** Open the window.
- **/
-
- window = WindowOpen( WA_Main );
- }
-
- return( window );
- }
-
- /*
- The following function, Update, is called in StartDemo (below)
- every time the user clicks on the slider.
- */
-
- void Update( void )
- {
- static long num = 0;
-
- puts( "Reached update function.\n" );
-
- /*
- The following SetAttrs lines do nothing.
- Shouldn't they change the gadget's value?
- */
-
- SetAttrs( outputIndicator, INDIC_Level, num++, TAG_END );
- SetAttrs( outputString, LAB_Label, "new!", TAG_END );
- SetAttrs( outputButton, LAB_Label, "new!", TAG_END );
- SetAttrs( outputInfo, INFO_TextFormat, ISEQ_C "new!", TAG_END );
-
- /*
- The following SetGadgetAttrs lines freeze the mouse for a moment,
- but don't change the gadget's value.
- */
-
- /* SetGadgetAttrs(
- ( struct Gadget * )outputIndicator,
- WA_Main, NULL, INDIC_Level, num++, TAG_END ); */
- /* SetGadgetAttrs(
- ( struct Gadget * )outputString,
- WA_Main, NULL, LAB_Label, "new!", TAG_END ); */
- /* SetGadgetAttrs(
- ( struct Gadget * )outputButton,
- WA_Main, NULL, LAB_Label, "new!", TAG_END ); */
- /* SetGadgetAttrs(
- ( struct Gadget * )outputInfo,
- WA_Main, NULL, INFO_TextFormat, ISEQ_C "new!", TAG_END ); */
- }
-
- long value;
-
- /*
- ** Main entry.
- **/
- VOID StartDemo( void )
- {
- struct Window *main = NULL, *sigwin = ( struct Window * )~0;
- ULONG sigmask = 0L, sigrec, rc, appsig = 0L;
- BOOL running = TRUE;
-
- /*
- ** Create the shared message port.
- **/
- if ( SharedPort = CreateMsgPort()) {
- /*
- ** Open the main window.
- **/
- if ( main = OpenMainWindow( &appsig )) {
- /*
- ** OR signal masks.
- **/
- sigmask |= ( appsig | ( 1L << SharedPort->mp_SigBit ));
- /*
- ** Loop...
- **/
- do {
- /*
- ** Wait for the signals to come.
- **/
- sigrec = Wait( sigmask );
-
- /*
- ** Find out which window signalled us.
- **/
- if ( sigrec & ( 1 << SharedPort->mp_SigBit )) {
- while ( sigwin = GetSignalWindow( WA_Main )) {
-
- /*
- ** Main window signal?
- **/
- if ( sigwin == main ) {
- /*
- ** Call the main-window event handler.
- **/
- while (( rc = HandleEvent( WA_Main )) != WMHI_NOMORE ) {
- switch ( rc ) {
-
- case WMHI_CLOSEWINDOW:
- case ID_QUIT:
- running = FALSE;
- break;
-
- case ID_INPUT:
- /*
- At each slider input, print value and
- call Update to try changing output gadgets.
- */
- GetAttr( SLIDER_Level, inputSlider, &value );
- printf( "value=%ld\n", value );
- Update();
- break;
- }
- }
- }
- }
- }
- } while ( running );
- }
- /*
- ** Dispose of all window objects.
- **/
- if ( WA_Main ) DisposeObject( WA_Main );
- /*
- ** Delete the shared message port.
- **/
- DeleteMsgPort( SharedPort );
- } else
- Tell( "Unable to create a message port.\n" );
- }
-
- /********************* democode.h ********************/
-
- /*
- * DEMOCODE.H
- *
- * (C) Copyright 1995 Jaba Development.
- * (C) Copyright 1995 Jan van den Baard.
- * All Rights Reserved.
- */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <libraries/gadtools.h>
- #include <libraries/bgui.h>
- #include <libraries/bgui_macros.h>
- #include <intuition/sghooks.h>
- #include <graphics/gfxmacros.h>
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
-
- #include <clib/alib_protos.h>
-
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/dos.h>
- #include <proto/bgui.h>
- #include <proto/graphics.h>
- #include <proto/diskfont.h>
-
- #include <stdlib.h>
-
- #ifdef _DCC
- #define SAVEDS __geta4
- #define ASM
- #define REG(x) __ ## x
- #define CHIP(t) __chip t
- #else
- #define SAVEDS __saveds
- #define ASM __asm
- #define REG(x) register __ ## x
- #define CHIP(t) t chip
- #endif
-
- /*
- * The entry point of all demo programs.
- */
- extern VOID StartDemo( void );
-
- /*
- * Output file handle and BGUI
- * library base.
- */
- BPTR StdOut;
- struct Library *BGUIBase;
-
- /*
- * Output text to the CLI or Workbench console.
- */
- VOID Tell( UBYTE *fstr, ... )
- {
- if ( StdOut ) VFPrintf( StdOut, fstr, ( ULONG * )&fstr + 1 );
- }
-
- /*
- * Main entry point.
- */
- int main( int argc, char **argv )
- {
- struct Process *this_task = ( struct Process * )FindTask( NULL );
- BOOL is_wb = FALSE;
-
- if ( this_task->pr_CLI )
- /*
- * Started from the CLI. Simply pickup
- * the CLI output handle.
- */
- StdOut = Output();
- else {
- /*
- * Workbench startup. Open a console
- * for output.
- */
- StdOut = Open( "CON:10/10/500/100/BGUI Demo Output/WAIT/AUTO", MODE_NEWFILE );
- is_wb = TRUE;
- }
-
- /*
- * Open BGUI.
- */
- if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
- /*
- * Run the demo.
- */
- StartDemo();
- CloseLibrary( BGUIBase );
- } else
- Tell( "Unable to open %s version %ld\n", BGUINAME, BGUIVERSION );
-
- /*
- * Close console if ran from
- * the workbench.
- */
- if ( is_wb ) {
- if ( StdOut ) Close( StdOut );
- }
-
- return( 0 );
- }
-
- /*
- * DICE stub which simply calls
- * main() when run from the
- * workbench.
- */
- #ifdef _DCC
- int wbmain( struct WBStartup *wbs )
- {
- return( main( NULL, 0 ));
- }
- #endif
-
- /********************* end of post ********************/
-